package com.fuyao.cloud.admin.flow.controller;

import com.fuyao.cloud.admin.flow.dto.*;
import com.fuyao.cloud.admin.flow.model.PagerModel;
import com.fuyao.cloud.admin.flow.service.flowable.IFlowableTaskService;
import com.fuyao.cloud.common.core.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@Api(value = "flowable", tags = "流程流转意见")
@RequestMapping("/flowable/task")
public class FlowableTaskController {

    private final IFlowableTaskService flowableTaskService;

    @ApiOperation(value = "查询我的待办任务总数")
    @ApiImplicitParam(name = "getAppingTaskCont", value = "查询参数", required = true, dataTypeClass = TaskQueryParamsVo.class, paramType = "body")
    @PostMapping(value = "/getAppingTaskCont", produces = "application/json")
    public R<Long> getAppingTaskCont(@RequestBody TaskQueryParamsVo params) {
        return R.ok(flowableTaskService.getAppingTaskCont(params));
    }

    @ApiOperation(value = "查询我的待办任务")
    @ApiImplicitParam(name = "getAppingTasksPagerModel", value = "分页查询参数", required = true, dataTypeClass = ParamVo.class, paramType = "body")
    @PostMapping(value = "/getAppingTasksPagerModel", produces = "application/json")
    public R<PagerModel<TaskVo>> getAppingTasksPagerModel(@RequestBody ParamVo<TaskQueryParamsVo> taskQueryParamsVoParamVo) {
        return R.ok(flowableTaskService.getAppingTasksPagerModel(taskQueryParamsVoParamVo.getEntity(), taskQueryParamsVoParamVo.getQuery()));
    }

    @ApiOperation(value = "查询我的已办任务")
    @ApiImplicitParam(name = "getApplyedTasksPagerModel", value = "分页查询参数", required = true, dataTypeClass = ParamVo.class, paramType = "body")
    @PostMapping(value = "/getApplyedTasksPagerModel", produces = "application/json")
    public R<PagerModel<TaskVo>> getApplyedTasksPagerModel(@RequestBody ParamVo<TaskQueryParamsVo> taskQueryParamsVoParamVo) {
        return R.ok(flowableTaskService.getApplyedTasksPagerModel(taskQueryParamsVoParamVo.getEntity(), taskQueryParamsVoParamVo.getQuery()));
    }

    @ApiOperation(value = "查询我的已发任务")
    @ApiImplicitParam(name = "getMySendTaskPageModel", value = "分页查询参数", required = true, dataTypeClass = ParamVo.class, paramType = "body")
    @PostMapping(value = "/getMySendTaskPageModel", produces = "application/json")
    public R<PagerModel<ProcessInstanceVo>> getMySendTaskPageModel(@RequestBody ParamVo<InstanceQueryParamsVo> ParamVo) {
        return R.ok(flowableTaskService.getMySendTaskPageModel(ParamVo.getEntity(), ParamVo.getQuery()));
    }

}
